<!--
 * @Descripttion:
 * @version:
 * @Author: 周子尧
 * @Date: 2021-01-22 15:55:40
 * @LastEditors: 周子尧
 * @LastEditTime: 2021-02-02 16:49:37
-->
<template>
  <div class="icons-container">
    <el-tabs type="border-card">
      <el-tab-pane label="Icons">
        <div class="grid">
          <div v-for="item of svgIcons" :key="item" @click="handleClipboard(generateIconCode(`svg ${item}`),$event)">
            <el-tooltip placement="top">
              <div slot="content">
                {{ generateIconCode(`svg ${item}`) }}
              </div>
              <div class="icon-item">
                <icon :value="`svg ${item}`" />
                <span>{{ item }}</span>
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="Element-UI Icons">
        <div class="grid">
          <div v-for="item of elementIcons" :key="item" @click="handleClipboard(generateIconCode('el-icon-' + item),$event)">
            <el-tooltip placement="top">
              <div slot="content">
                {{ generateIconCode('el-icon-' + item) }}
              </div>
              <div class="icon-item">
                <icon :value="'el-icon-' + item" />
                <span>{{ item }}</span>
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="IconFont Icons">
        <div class="grid">
          <div v-for="item of aliIcons" :key="item" @click="handleClipboard(generateIconCode('iconfont ' + item),$event)">
            <el-tooltip placement="top">
              <div slot="content">
                {{ generateIconCode('iconfont ' + item) }}
              </div>
              <div class="icon-item">
                <icon :value="'iconfont ' + item" />
                <span>{{ item }}</span>
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="Awesome Icons">
        <div class="grid">
          <div v-for="item of faIcons" :key="item" @click="handleClipboard(generateIconCode('fa ' + item),$event)">
            <el-tooltip placement="top">
              <div slot="content">
                {{ generateIconCode('fa ' + item) }}
              </div>
              <div class="icon-item">
                <icon :value="'fa ' + item" />
                <span>{{ item }}</span>
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import clipboard from '@/utils/clipboard'
import svgIcons from './svg-icons'
import elementIcons from './element-icons'
import aliIcons from './ali-icons'
import faIcons from './awesome'

export default {
  name: 'Icons',
  data() {
    return {
      svgIcons,
      elementIcons,
      aliIcons,
      faIcons
    }
  },
  methods: {
    generateIconCode(symbol) {
      return `<icon value="${symbol}" />`
    },
    handleClipboard(text, event) {
      clipboard(text, event)
    }
  }
}
</script>

<style lang="scss" scoped>
.icons-container {
  margin: 10px 20px 0;
  overflow: hidden;

  .grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .icon-item {
    margin: 20px;
    height: 85px;
    text-align: center;
    width: 100px;
    float: left;
    font-size: 30px;
    color: #24292e;
    cursor: pointer;
  }

  span {
    display: block;
    font-size: 16px;
    margin-top: 10px;
  }

  .disabled {
    pointer-events: none;
  }
}
</style>
